-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expire azure token as needed #615
Conversation
|
||
export async function createAzureToken( | ||
signal: AbortSignal | ||
): Promise<AuthenticationToken> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter signal
in the function createAzureToken
is missing a type annotation. Please add a type annotation to improve code readability and maintainability. 📚
generated by pr-review-commit
missing_param_type
if ( | ||
!this._azureToken || | ||
this._azureToken.expiresOnTimestamp >= Date.now() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comparison this._azureToken.expiresOnTimestamp >= Date.now()
seems to be incorrect. It should be this._azureToken.expiresOnTimestamp <= Date.now()
to check if the token has expired. 🕰️
generated by pr-review-commit
incorrect_comparison
if ( | ||
!this._azureToken || | ||
this._azureToken.expiresOnTimestamp >= Date.now() | ||
) | ||
this._azureToken = await createAzureToken(signal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function createAzureToken
is an async function but it's not being awaited here. This could lead to unexpected behavior. Please use await
to ensure the promise is resolved before proceeding. 🔄
generated by pr-review-commit
async_await
There are some potential functional issues in the pull request:
- this._azureToken.expiresOnTimestamp >= Date.now()
+ this._azureToken.expiresOnTimestamp <= Date.now()
- !this._azureToken ||
- this._azureToken.expiresOnTimestamp >= Date.now()
+ !this._azureToken ||
+ (typeof this._azureToken.expiresOnTimestamp === 'number' && this._azureToken.expiresOnTimestamp <= Date.now()) These changes should make the code safer and functionally correct.
|
fix for #613 |
createAzureToken
inazuretoken.ts
has been refactored to return an object of typeAuthenticationToken
. This marks a shift from the previous version where it just returned a string token, to the new version where it returns an object containing two properties,token
(a string) andexpiresOnTimestamp
(a number). 🔄AuthenticationToken
was introduced intoazuretoken.ts
. 🆕_azureToken
private property innodehost.ts
has been altered to hold anAuthenticationToken
object as opposed to a single token string. 💾getLanguageModelConfiguration
innodehost.ts
has been updated to refresh the_azureToken
if it is not set, or if itsexpiresOnTimestamp
is equal to or greater than the current time. This ensures that an expired token won't be used, improving reliability and security. ⏲️🔒getLanguageModelConfiguration
now uses_azureToken.token
as opposed to_azureToken
. 👍